package com.rf.richfitwheel.admin.sys.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rf.richfitwheel.admin.sys.model.RoleMenu;
import com.rf.richfitwheel.admin.sys.service.SysRoleMenuService;

import java.util.ArrayList;
import java.util.List;



/**
 * 角色与菜单对应关系
 * 
 */
@Service("sysRoleMenuService")
public class SysRoleMenuServiceImpl  implements SysRoleMenuService {

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void saveOrUpdate(Long roleId, List<Long> menuIdList) {
		//先删除角色与菜单关系
		deleteBatch(new Long[]{roleId});

		if(menuIdList.size() == 0){
			return ;
		}

		//保存角色与菜单关系
		List<RoleMenu> list = new ArrayList<RoleMenu>(menuIdList.size());
		for(Long menuId : menuIdList){
			RoleMenu sysRoleMenuEntity = new RoleMenu();
//			sysRoleMenuEntity.setMenuId(menuId);
//			sysRoleMenuEntity.setRoleId(roleId);

			list.add(sysRoleMenuEntity);
		}
//		this.insertBatch(list);
	}

	@Override
	public List<Long> queryMenuIdList(Long roleId) {
		return null;//baseMapper.queryMenuIdList(roleId);
	}

	@Override
	public int deleteBatch(Long[] roleIds){
		return 0;// baseMapper.deleteBatch(roleIds);
	}

}
